Imports Microsoft.VisualBasic

Friend Class SendMailObject_ASPMAIL
    Inherits SendMailObject_Base

    Private msPriority() As String = {"Normal", "High", "Low"}

    Public Sub New(ByVal sEmailServer As String)
        MyBase.New(sEmailServer)
    End Sub

    Public Overrides Function SendMessage( _
            ByVal oMessage As Message) As String

        Dim sResult As String = ""

        Try
            Dim oMailer As Object = CreateObject("ASPMAIL.ASPMailCtrl.1")

            '---Documentation for ASPMAIL.ASPMail.Ctrl.1 - SendX method
            '   http://www.wiredhosting.com/selfhelp/aspmail/mail_features.asp

            'mailServer
            '   Specifies the name of SMTP mail server. 
            'fromName
            '   The informal name of the person sending the email message. Can be empty.
            '   An error will result if both fromName and fromAddress are empty. 
            'fromAddress
            '   The email address of the person sending the email message. Can be empty.
            '   An error will result if both fromName and fromAddress are empty. 
            'priority
            '   The priority of the message. Can be empty or one of "Highest", "High", 
            '   "Low", "Lowest". 
            'returnReceipt
            '   If empty does nothing. If it has a value of "Yes" then requests a return 
            '   receipt from the recipients. 
            'toAddressList
            '   The email address of the person to whom the electronic mail message will 
            '   be sent. Can be empty. Multiple recipients separated by a comma only. An 
            '   error will result if toAddressList and ccAddressList and bccAddressList are empty. 
            'ccAddressList
            '   The email address of the person to whom the electronic mail message will be 
            '   carbon-copied. Can be empty. Multiple recipients separated by a comma only.
            '   An error will result if toAddressList and ccAddressList and bccAddressList are empty. 
            'bccAddressList
            '   The email address of the person to whom the electronic mail message will be blind 
            '   carbon-copied. Can be empty. Multiple recipients separated by a comma only. 
            '   An error will result if toAddressList and ccAddressList and bccAddressList are empty. 
            'attach
            '   The file to be attached. Multiple attachments separated by a comma only. Can be empty. 
            'messageSubject
            '   The subject of the message. Can be empty. An error will result if both messageSubject 
            '   and messageText are empty. 
            'messageText
            '   The text of the message. Can be empty. An error will result if both messageSubject 
            '   and messageText are empty.

            Dim sPriority As Message.MsgPriority = msPriority(oMessage.Priority)
            Dim sReturnReceipt As String = ""
            If oMessage.ReturnReceipt Then
                sReturnReceipt = "Yes"
            End If

            sResult = oMailer.SendX( _
                            msEmailServer, _
                            oMessage.SenderName, _
                            oMessage.SenderEmail, _
                            sPriority, _
                            sReturnReceipt, _
                            oMessage.RecipientAddressList, _
                            oMessage.RecipientCCList, _
                            oMessage.RecipientBCCList, _
                            oMessage.RecipientBCCList, _
                            oMessage.Subject, _
                            oMessage.Message)

        Catch ex As Exception
            sResult = ex.Message.ToString
        End Try

        Return sResult
    End Function
End Class